-
Notifications
You must be signed in to change notification settings - Fork 648
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a configuration manager #466
Conversation
88f47e9
to
fdcc761
Compare
34ec861
to
3354416
Compare
Co-Authored-By: Chris Kleinknecht <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but two questions:
I see examples that used to call set_preferred_implementation
with an SDK object don't call set_provider
now. Is this because you expect users to set the SDK objects in config instead? If so we probably need to include that in the docs.
Many tests set providers, but don't unset them. It looks like this isn't a problem in practice because tests that rely on a certain provider set it themselves, but we should avoid side effects like this.
@@ -12,14 +12,12 @@ | |||
# See the License for the specific language governing permissions and | |||
# limitations under the License. | |||
|
|||
import os | |||
from os.path import dirname, join |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this change?
from opentelemetry.sdk.metrics.export.controller import PushController | ||
|
||
# Meter is responsible for creating and recording metrics | ||
metrics.set_preferred_meter_provider_implementation(lambda _: MeterProvider()) | ||
meter = metrics.get_meter(__name__) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This returns an api DefaultMeter
now instead of a sdk Meter
, shouldn't we have this line above?
metrics.set_meter_provider(sdk.metrics.MeterProvider())
Or is it intentional that the examples only use the API types? I think it'd be more helpful to show using the SDK since that's how most users will do it.
( | ||
metrics._METER_PROVIDER, | ||
metrics._METER_PROVIDER_FACTORY, | ||
) = cls._meter_defaults |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like tests that set the meter/tracer provider on setup should still unset it on teardown. Why remove this instead of update it?
We've got two approvals and it looks like @ocelotl has addressed all the open comments, fixing a typo and merging. |
Add the new configuration module from #466 to the generated docs. Co-authored-by: Diego Hurtado <[email protected]> Co-authored-by: Mauricio Vásquez <[email protected]>
tracer = trace.get_tracer(__name__) | ||
|
||
# SpanExporter receives the spans and send them to the target location. | ||
span_processor = BatchExportSpanProcessor(exporter) | ||
trace.tracer_provider().add_span_processor(span_processor) | ||
trace.set_tracer_provider(TracerProvider()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be done before L42, otherwise the returned tracer will be de default one. I pushed a fix as a part of a747b61.
Total Changelog: Documentations has been significantly overhauled, including: * a getting started guide * examples has been consolidated to an docs/examples folder * several minor improvements to the examples in each extension's readme. - Adding Correlation Context API and propagator ([open-telemetry#471](open-telemetry#471)) - Adding a global configuration module to simplify setting and getting globals ([open-telemetry#466](open-telemetry#466)) - Rename metric handle to bound metric ([open-telemetry#470](open-telemetry#470)) - Moving resources to sdk ([open-telemetry#464](open-telemetry#464)) - Implementing propagators to API to use context ([open-telemetry#446](open-telemetry#446)) - Implement observer instrument for metrics ([open-telemetry#425](open-telemetry#425)) - Adding named meters, removing batchers ([open-telemetry#431](open-telemetry#431)) - Renaming TraceOptions to TraceFlags ([open-telemetry#450](open-telemetry#450)) - Renaming TracerSource to TraceProvider ([open-telemetry#441](open-telemetry#441)) - Adding Correlation Context SDK and propagator ([open-telemetry#471](open-telemetry#471)) - Adding OT Collector metrics exporter ([open-telemetry#454](open-telemetry#454)) - Improve validation of attributes ([open-telemetry#460](open-telemetry#460)) - Re-raise errors caught in opentelemetry.sdk.trace.Tracer.use_span() (open-telemetry#469) ([open-telemetry#469](open-telemetry#469)) - Adding named meters, removing batchers ([open-telemetry#431](open-telemetry#431)) - Make counter and MinMaxSumCount aggregators thread safe ([open-telemetry#439](open-telemetry#439)) - Initial release. Support is included for both trace and metrics.
Total Changelog: Documentations has been significantly overhauled, including: * a getting started guide * examples has been consolidated to an docs/examples folder * several minor improvements to the examples in each extension's readme. - Adding Correlation Context API and propagator ([open-telemetry#471](open-telemetry#471)) - Adding a global configuration module to simplify setting and getting globals ([open-telemetry#466](open-telemetry#466)) - Rename metric handle to bound metric ([open-telemetry#470](open-telemetry#470)) - Moving resources to sdk ([open-telemetry#464](open-telemetry#464)) - Implementing propagators to API to use context ([open-telemetry#446](open-telemetry#446)) - Implement observer instrument for metrics ([open-telemetry#425](open-telemetry#425)) - Adding named meters, removing batchers ([open-telemetry#431](open-telemetry#431)) - Renaming TraceOptions to TraceFlags ([open-telemetry#450](open-telemetry#450)) - Renaming TracerSource to TraceProvider ([open-telemetry#441](open-telemetry#441)) - Adding Correlation Context SDK and propagator ([open-telemetry#471](open-telemetry#471)) - Adding OT Collector metrics exporter ([open-telemetry#454](open-telemetry#454)) - Improve validation of attributes ([open-telemetry#460](open-telemetry#460)) - Re-raise errors caught in opentelemetry.sdk.trace.Tracer.use_span() (open-telemetry#469) ([open-telemetry#469](open-telemetry#469)) - Adding named meters, removing batchers ([open-telemetry#431](open-telemetry#431)) - Make counter and MinMaxSumCount aggregators thread safe ([open-telemetry#439](open-telemetry#439)) - Initial release. Support is included for both trace and metrics.
Fixes #123
This basically removes
loader.py
(uses entry points instead) and all the calls forset_preferred_implementation*
in order to cleanly separate user code from configuration. It introduces a configuration manager that can have configuration set by a configuration file (for the moment just a JSON file, probably a more suitable format would be ideal) or environment variables that override the former configuration method.A couple test environments are still failing (mypy and tracecontext). Opening still to receive input.